package logic

import (
	"com-man-sys/comrpc/comrpc"
	"com-man-sys/comrpc/internal/svc"
	"com-man-sys/models/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *comrpc.UserListRequest) (*comrpc.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.UserShang
	var list []*comrpc.UserList

	var err error
	list, err = user.UserFind(mysql.DB, list, in)
	if err != nil {
		return nil, err
	}

	return &comrpc.UserListResponse{
		List: list,
	}, nil
}
